package com.luckymore.ydd.app.model;

import com.base.model.Bean2Json;

import org.json.JSONArray;

import java.util.ArrayList;
import java.util.List;

public class MAppEssence {

	static public class MEssenceList extends Bean2Json<MEssenceList> {
		private static final long serialVersionUID = 1L;
		private List<MEssence> essence = new ArrayList<MEssence>();
		public List<MEssence> getEssence() {
			return this.essence;
		}
		public void setEssence(List<MEssence> essence) {
			this.essence=essence;
		}
		public MEssenceList build() throws Exception {
			JSONArray jaessence = data.getJSONArray("essence_");
			for(int i = 0, len = jaessence.length(); i < len; i++) {
				MEssence n = new MEssence();n.setData(jaessence.getJSONObject(i));this.essence.add(n);
			}
			return this;
		}
		public void build(Bean2Json data) {
			this.setEssence(((MEssenceList)data).getEssence());
		}

	}

	static public class MEssence extends Bean2Json<MEssence> {
		private static final long serialVersionUID = 1L;
		private String id;
		private String title;
		private String source;
		private String url;
		private String content;
		private int hasDownload;
		private int is_collected;
		private int is_downloaded;
		private int need_share;
		private String time;
		private int type;
		private int resType;
		private String resSize;
		private int browseTimes;
		private int downloadTimes;
		private int subjectType;
		private String subjectName;
		private List<MEssenceMedia> media = new ArrayList<MEssenceMedia>();
		private String shareUrl;
		public String getId() {
			return this.id;
		}
		public void setId(String id) {
			this.id=id;
		}
		public String getTitle() {
			return this.title;
		}
		public void setTitle(String title) {
			this.title=title;
		}
		public String getSource() {
			return this.source;
		}
		public void setSource(String source) {
			this.source=source;
		}
		public String getUrl() {
			return this.url;
		}
		public void setUrl(String url) {
			this.url=url;
		}
		public String getContent() {
			return this.content;
		}
		public void setContent(String content) {
			this.content=content;
		}
		public int getHasDownload() {
			return this.hasDownload;
		}
		public void setHasDownload(int hasDownload) {
			this.hasDownload=hasDownload;
		}
		public int getIs_collected() {
			return this.is_collected;
		}
		public void setIs_collected(int is_collected) {
			this.is_collected=is_collected;
		}
		public int getIs_downloaded() {
			return this.is_downloaded;
		}
		public void setIs_downloaded(int is_downloaded) {
			this.is_downloaded=is_downloaded;
		}
		public int getNeed_share() {
			return this.need_share;
		}
		public void setNeed_share(int need_share) {
			this.need_share=need_share;
		}
		public String getTime() {
			return this.time;
		}
		public void setTime(String time) {
			this.time=time;
		}
		public int getType() {
			return this.type;
		}
		public void setType(int type) {
			this.type=type;
		}
		public int getResType() {
			return this.resType;
		}
		public void setResType(int resType) {
			this.resType=resType;
		}
		public String getResSize() {
			return this.resSize;
		}
		public void setResSize(String resSize) {
			this.resSize=resSize;
		}
		public int getBrowseTimes() {
			return this.browseTimes;
		}
		public void setBrowseTimes(int browseTimes) {
			this.browseTimes=browseTimes;
		}
		public int getDownloadTimes() {
			return this.downloadTimes;
		}
		public void setDownloadTimes(int downloadTimes) {
			this.downloadTimes=downloadTimes;
		}
		public int getSubjectType() {
			return this.subjectType;
		}
		public void setSubjectType(int subjectType) {
			this.subjectType=subjectType;
		}
		public String getSubjectName() {
			return this.subjectName;
		}
		public void setSubjectName(String subjectName) {
			this.subjectName=subjectName;
		}
		public List<MEssenceMedia> getMedia() {
			return this.media;
		}
		public void setMedia(List<MEssenceMedia> media) {
			this.media=media;
		}
		public String getShareUrl() {
			return this.shareUrl;
		}
		public void setShareUrl(String shareUrl) {
			this.shareUrl=shareUrl;
		}
		public MEssence build() throws Exception {
			this.setId(data.getString("id_"));
			this.setTitle(data.getString("title_"));
			this.setSource(data.getString("source_"));
			this.setUrl(data.getString("url_"));
			this.setContent(data.getString("content_"));
			this.setHasDownload(data.getInt("hasDownload_"));
			this.setIs_collected(data.getInt("isCollected_"));
			this.setIs_downloaded(data.getInt("isDownloaded_"));
			this.setNeed_share(data.getInt("needShare_"));
			this.setTime(data.getString("time_"));
			this.setType(data.getInt("type_"));
			this.setResType(data.getInt("resType_"));
			this.setResSize(data.getString("resSize_"));
			this.setBrowseTimes(data.getInt("browseTimes_"));
			this.setDownloadTimes(data.getInt("downloadTimes_"));
			this.setSubjectType(data.getInt("subjectType_"));
			this.setSubjectName(data.getString("subjectName_"));
			JSONArray jamedia = data.getJSONArray("media_");
			for(int i = 0, len = jamedia.length(); i < len; i++) {
				MEssenceMedia n = new MEssenceMedia();n.setData(jamedia.getJSONObject(i));this.media.add(n);
			}
			this.setShareUrl(data.getString("shareUrl_"));
			return this;
		}
		public void build(Bean2Json data) {
			this.setId(((MEssence)data).getId());
			this.setTitle(((MEssence)data).getTitle());
			this.setSource(((MEssence)data).getSource());
			this.setUrl(((MEssence)data).getUrl());
			this.setContent(((MEssence)data).getContent());
			this.setHasDownload(((MEssence)data).getHasDownload());
			this.setIs_collected(((MEssence)data).getIs_collected());
			this.setIs_downloaded(((MEssence)data).getIs_downloaded());
			this.setNeed_share(((MEssence)data).getNeed_share());
			this.setTime(((MEssence)data).getTime());
			this.setType(((MEssence)data).getType());
			this.setResType(((MEssence)data).getResType());
			this.setResSize(((MEssence)data).getResSize());
			this.setBrowseTimes(((MEssence)data).getBrowseTimes());
			this.setDownloadTimes(((MEssence)data).getDownloadTimes());
			this.setSubjectType(((MEssence)data).getSubjectType());
			this.setSubjectName(((MEssence)data).getSubjectName());
			this.setMedia(((MEssence)data).getMedia());
			this.setShareUrl(((MEssence)data).getShareUrl());
		}

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            MEssence mEssence = (MEssence) o;

            if (id != null ? !id.equals(mEssence.id) : mEssence.id != null) return false;

            return true;
        }

        @Override
        public int hashCode() {
            return id != null ? id.hashCode() : 0;
        }
    }

	static public class MEssenceMedia extends Bean2Json<MEssenceMedia> {
		private static final long serialVersionUID = 1L;
		private int number;
		private String url;
		public int getNumber() {
			return this.number;
		}
		public void setNumber(int number) {
			this.number=number;
		}
		public String getUrl() {
			return this.url;
		}
		public void setUrl(String url) {
			this.url=url;
		}
		public MEssenceMedia build() throws Exception {
			this.setNumber(data.getInt("number_"));
			this.setUrl(data.getString("url_"));
			return this;
		}
		public void build(Bean2Json data) {
			this.setNumber(((MEssenceMedia)data).getNumber());
			this.setUrl(((MEssenceMedia)data).getUrl());
		}

	}


}
